from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

from commom.Utils import WebChatDriver
from selenium.webdriver.support import expected_conditions as EC


class WebChatUnLogin:
    driver=""
    url=""
    def __init__(self):
        self.driver=WebChatDriver.driver
        self.url="http://127.0.0.1:8080/client.html"
        self.driver.get(self.url)
    #测试未登录下的登录好友列表
    def ListTestByUnLogin(self):
        print("-----测试非登录下的好友界面-----")

        wait = WebDriverWait(self.driver, 5)
        # 等待直到页面出现警告框，满足这个条件才会继续往下执行
        alert = wait.until(EC.alert_is_present())
        alert=self.driver.switch_to.alert
        text=alert.text
        assert text == "当前用户未登录!"
        alert.accept()
        #检查是否回到登录界面
        self.driver.find_element(By.CSS_SELECTOR, "body > div.login-container > div > h3")
        WebChatDriver.getScreeShot()
        print("----测试非登录下的好友界面-----[pass]\n")